package com.dao.zk;
import com.util.zk.Dbutil;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.MapListHandler;
import org.springframework.stereotype.Repository;
import java.sql.Connection;
import java.util.List;
import java.util.Map;
@Repository
public class DeptDAO {

    /**
     * 查询所有的部门
     */
    public List<Map<String, Object>> selDepts(){
        Connection con = null;
        QueryRunner query = new QueryRunner();
        List<Map<String, Object>> depts =null;
        try {
            con = Dbutil.getConnection();
            String sql = "select did,dname from dept ;";
            depts = query.query(con, sql, new MapListHandler());
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            Dbutil.closeAll(null,null,con);
        }
        return  depts;
    }
}
